#include "StdAfx.h"
#include "AlgorithmAnlysis.h"





CAlgorithmAnlysis::CAlgorithmAnlysis(void)
{
}


CAlgorithmAnlysis::~CAlgorithmAnlysis(void)
{
}

int CAlgorithmAnlysis::Pow1(int iX, int iN)
{
	//CRunTimeCalc RunTimeCalc("Pow1");

	if (iN == 0)
		return 1;
	if (iN == 1)
		return iX;
	if (iN %2 == 0)
		return Pow1(iX * iX, iN/2);
	else
		return Pow1(iX * iX, iN/2) * iX;
}

int CAlgorithmAnlysis::Pow2(int iX, int iN)
{
	//CRunTimeCalc RunTimeCalc("Pow2");

	int iTmp = iX;
	for (int i=0; i<iN/2; i++)
	{
		iTmp *= iX;
	}

	iTmp *= iX;

	return iTmp;
}